package view.panel
{
	import flash.display.Sprite;
	import flash.events.TimerEvent;
	import flash.filters.GlowFilter;
	import flash.text.TextField;
	
	import utils.EnterFrameTimer;
	import utils.TextTool;
	
	public class PlayBottomHint extends Sprite
	{
		private var timer:EnterFrameTimer;
		private var hintTime:int = 5 * 10;
		private var leftTime:int = 5 * 10;
		
		private var hintText:TextField;
		private var content:String;
		private var initColor:int = 0xFFFF00;
		private var glowFilter:GlowFilter;
		
		public function PlayBottomHint()
		{
			initTimer();
			initText();
		}
		
		private function initText():void
		{
			hintText = TextTool.getTextField(260,20,12,0xFFFFFF,false,false,"center");
			addChild(hintText);
			
			glowFilter = new GlowFilter(0xFF9900,.7,2,2,2);
			
			
		}
		
		private function initTimer():void
		{
			timer = new EnterFrameTimer(100);
			timer.addEventListener(TimerEvent.TIMER,onTimer);
		}
		
		private function onTimer(event:TimerEvent):void
		{
			var p:Number = leftTime / hintTime * 3;
			if (p > 1)
			{
				p = 1;
			}
			hintText.text = this.content;
			//hintText.textColor = (int(0xFF * p)  << 16) + ( int(0xFF * p) << 8); 
			hintText.textColor = (int(0xFF * p)  << 16) + ( int(0xFF * p) << 8) + int(0xFF * p); 
			leftTime--;	
			if (leftTime <=0)
			{
				stop();
			}
			
			if (p < .4)
			{
				hintText.filters = null;
			}
		}
		
		public function hint(content:String):void
		{
			this.content = content;
			leftTime = hintTime;
			timer.start();
			hintText.filters = [glowFilter];
		}
		
		public function stop():void
		{
			timer.stop();
			hintText.text = "";
		}
		
	}
}